#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenuBar *menubar = new QMenuBar(this);
    this->setMenuBar(menubar);

    QMenu *menu1 = new QMenu("文件 (&F)");
    QMenu *menu2 = new QMenu("编辑 (&E)");
    QMenu *menu3 = new QMenu("视图 (&V)");
    menubar->addMenu(menu1);
    menubar->addMenu(menu2);
    menubar->addMenu(menu3);

    QAction *action1 = new QAction("打开项目 (&Q)");
    QAction *action2 = new QAction("关闭项目 (&p)");
    QAction *action3 = new QAction("删除项目 (&Z)");
    menu1->addAction(action1);
    menu2->addAction(action2);
    menu3->addAction(action3);

    connect(action1,&QAction::triggered,this,&MainWindow::handle1);
    connect(action2,&QAction::triggered,this,&MainWindow::handle2);
    connect(action3,&QAction::triggered,this,&MainWindow::handle3);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::handle1()
{
    qDebug() << "打开项目";
}

void MainWindow::handle2()
{
    qDebug() << "关闭项目";
}

void MainWindow::handle3()
{
    qDebug() << "删除项目";
}
